package org.example.controller;

import org.example.holder.PrototypeDataHolder;
import org.example.holder.RequestDataHolder;
import org.example.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 控制器类 - 演示prototype和request作用域的区别
 */
@RestController
public class ScopeController {
    

    @Autowired
    private MyService myService;
    @Autowired
    private PrototypeDataHolder prototypeDataHolder;
    @Autowired
    private RequestDataHolder requestDataHolder;

    @GetMapping("/test-request")
    public void testRequest(@RequestParam(defaultValue = "请求数据") String data) {
        System.out.println(""+(myService.getRequestDataHolder()==this.requestDataHolder));
        System.out.println(""+(myService.getPrototypeDataHolder()==this.prototypeDataHolder));
    }
    


} 